package loengud.w08;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class SimpleStamper1 extends JApplet implements MouseListener {

	public void init() {
		// When the applet is created, set its background color
		// to black, and register the applet to listen to mouse
		// events on itself.
		setBackground(Color.black);
		addMouseListener(this);
	}

	public void mousePressed(MouseEvent evt) {
		if (evt.isShiftDown()) {
			repaint();
			return;
		}

		int x = evt.getX(); // x-coordinate where user clicked.
		int y = evt.getY(); // y-coordinate where user clicked.
		Graphics g = getGraphics(); // get Graphics context

		if (evt.isMetaDown()) {
			// Draw a blue oval centered at the point (x,y).
			g.setColor(Color.blue);
			g.fillOval(x - 25, y - 15, 60, 30);
			g.setColor(Color.black);
			g.drawOval(x - 25, y - 15, 60, 30);
		} else {

			// Draw a red rectangle centered at the point (x,y).
			g.setColor(Color.red);
			g.fillRect(x - 25, y - 15, 60, 30);
			g.setColor(Color.black);
			g.drawRect(x - 25, y - 15, 60, 30);
		}

		g.dispose(); // We are finished with the graphics context,
	} // -mousePressed
		// The following empty routines are required by the
	// MouseListener interface:

	public void mouseEntered(MouseEvent evt) {
	}

	public void mouseExited(MouseEvent evt) {
	}

	public void mouseClicked(MouseEvent evt) {
	}

	public void mouseReleased(MouseEvent evt) {
	}
} // end class SimpleStamper

